package main
import (
  "fmt"
  "os"
  "net/http"
  "log"
)

func main() {
  name := os.Getenv("NAME")
  hello := fmt.Sprintf("Hello %s ", name)
  http.Handle("/hello/", http.StripPrefix("/hello/", http.FileServer(http.Dir("static"))))
  f, err := os.OpenFile("./static/index.html", os.O_APPEND|os.O_WRONLY | os.O_CREATE, 0600)
  if err != nil {
    panic(err)
  }

  defer f.Close()
  if _, err = f.WriteString(hello); err != nil {

     panic(err)
  }

  port := os.Getenv("PORT")
  if port == "" {
    port = "9090"
  }

  log.Fatal(http.ListenAndServe(":9090", nil))
  println("finished")
}
